package com.leyou.item.client;

import com.leyou.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("item-service")
public interface ItemClient {

    /**
     * 分页查询商品信息
     */
    @GetMapping("/spu/page")
    PageResult<SpuDTO> findGoodsPage(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                     @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                     @RequestParam(value = "key", required = false) String key,
                                     @RequestParam(value = "saleable", required = false) Boolean saleable);

    /**
     * 根据spuID查询sku集合
     *
     * @param id
     * @return
     */
    @GetMapping("/sku/of/spu")
    List<SkuDTO> findSKus(@RequestParam("id") Long id);


    /**
     * 查询规格参数信息
     */
    @GetMapping("/spec/params")
    List<SpecParamDTO> findSpecParam(@RequestParam(value = "gid", required = false) Long gid
            , @RequestParam(value = "cid", required = false) Long cid
            , @RequestParam(value = "search", required = false) Boolean search);

    /**
     * 根据SPUID查询SPUDETAIL对象
     */
    @GetMapping("/spu/detail")
    SpuDetailDTO findSpuDetail(@RequestParam("id") Long id);

    @GetMapping("/category/list")
    List<CategoryDto> findCategoriesByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("/brand/{id}")
    BrandDto findById(@PathVariable("id") Long id);
}
